
{extend name='public/base' /}

{block name="content"}

<div class="layui-col-md12">
    <div class="layui-card">
        <div class="layui-card-body">
            <form action="" class="layui-form" method="get">
                <div class="layui-form-item layui-form-pane">
                    <div class="layui-inline">
                        <label class="layui-form-label" style="overflow: inherit;">合同号：</label>
                        <div class="layui-input-inline">
                            <input name="contract_code" class="layui-input" id="contract_code" value="" type="text"
                                   placeholder="合同号">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">商户：</label>
                        <div class="layui-input-inline">
                            <select name="merchant_id" lay-verify="required" lay-search="">
                                <option value="0" ></option>
                                {volist name="merchant_list" id="t"}
                                {if empty($t.name)||$t.name=='-'}
                                <option value="{$t.id}" >{$t.company} - {$t.code}-{$t.biz_state}-{$t.positions_code}</option>
                                {else/}
                                <option value="{$t.id}" >{$t.name} - {$t.code}-{$t.biz_state}-{$t.positions_code}</option>
                                {/if}
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label" style="overflow: inherit;">海鼎账单号：</label>
                        <div class="layui-input-inline">
                            <input name="billNubmer" class="layui-input" id="billNubmer" value="" type="text"
                                   placeholder="海鼎账单号">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn icon-btn layui-btn-sm" data-id="table_id" lay-filter="search" lay-submit="">
                            <i class="layui-icon"></i>搜索
                        </button>
                        <button type="reset" class="layui-btn icon-btn layui-btn-normal layui-btn-sm"><i class="layui-icon layui-icon-refresh"></i>{:__('Reset')}</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="layui-card">
        <div class="layui-card-body">
            <table class="layui-hide" id="table_id" lay-filter="table_id"></table>
        </div>
    </div>

</div>
{/block}

{block name="js"} <!--js处理区-->


<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <button type="button" lay-event="reload"  class="layui-btn  layui-btn-sm  layui-btn-primary">刷新表格</button>
        <button type="button" lay-event="audits"  class="layui-btn  layui-btn-sm {:node('CostAudit/audits')}">批量审核</button>
        <button type="button"  lay-event="auditall"  class="layui-btn  layui-btn-sm {:node('CostAudit/auditall')}">全部审核</button>
    </div>
</script>


<script type="text/html" id="operationTpl">
    <a href="javascript:;" class="layui-btn layui-btn-sm  {:node('CostAudit/audit')}" data-title="审核" lay-event="audit"><i class="layui-icon">&#xe705;</i></a>
</script>

<script>
    layui.use(['element', 'table', 'form', 'jquery', 'lucky','opTable'], function () {
        var element = layui.element;
        var form = layui.form;
        var table = layui.table;
        var $ = layui.jquery;
        var lucky=layui.lucky;
        var opTable = layui.opTable;
        form.render();

        var myTables = table.render({
            elem: '#table_id',
            url:"{:url('index')}",
            where: { info_type: 2},
            toolbar: '#toolbarDemo', //开启头部工具栏，并为其绑定左侧模板
            even: true, //开启隔行背景
            id:'table_id',
            page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip','last'] //自定义分页布局
                ,groups: 5 //只显示 1 个连续页码
                ,first: false //不显示首页
                ,last: false //不显示尾页
                ,limit:20
                ,limits:[10,20,30,50]
            },
              // height: 'full-100',100',
            text: {
                none: '暂无相关数据'
            },
            cols: [[
                { title: '', type: 'checkbox', fixed: true},
                { title: '缴费单编号', field: 'order_sn', edit: 'text',width:200},
                { title: '品牌名',width:100, field: 'merchant_user',templet:function (item) {
                        // +'('+item.merchant.mobile+')'
                        return item.merchant.name;
                    }, fixed:'left'},
                { title: '签约租户', width:200,field: 'merchant',templet:function (item) { return item.merchant.company}},
                {title: '合同号', field: 'merchant',width:200, templet: function (item) {
                        return item.merchant.code
                    }
                },
                // { title: '负责人信息', field: 'merchant_user',templet:function (item) { return item.merchant.username+'('+item.merchant.mobile+')'}},
                { title: '费用项', field: 'merchant',templet:function (item) { return item.costType.cost_name}},
                { title: '待缴金额(元)',width: 90, field: 'amount',templet:function (item) { return item.amount/100} },
                { title: '实收金额(元)',width: 90, field: 'pay_amount',templet:function (item) { return item.pay_amount/100} },
                { title: '账单金额(元)',width: 90, field: 'all_amount',templet:function (item) { return item.all_amount/100} },
                {
                    title: '缴费区间', field: 'create_time', width: 250, templet: function (item) {
                        if (item.start_time) {
                            return layui.util.toDateString((item.start_time) * 1000, 'yyyy-MM-dd') + '~' + layui.util.toDateString((item.end_time) * 1000, 'yyyy-MM-dd');
                        } else {
                            return '';
                        }
                    }
                },
                {templet: '#operationTpl', width: 200,align: 'center', title: '操作'}
            ]],
            //  展开的列配置
            openCols: [
            {field: 'desc', title: '描述信息'}
            ],
            done: function (res) {
                layer.closeAll('loading');
            }
        });


        /**
         * 监听单行工具操作
         */
        table.on('tool(table_id)', function (obj) {
            var data = obj.data;
            console.log(data)
            var _id=parseInt(data.id);
            var layEvent = obj.event;
            if(layEvent==="audit"){
                lucky.FormatData(_id,"{:url('audit')}","确认审核通过?");
                return false;
            }
        });
        table.on('toolbar(table_id)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            if(obj.event==="audits"){
                var num=0;
                var id=[];
                for (var i in data) {
                    num++;
                    id.push(data[i].id);
                }
                if (num<1) {
                    layer.msg("请选择一项",{time:1500});return false;
                }
                lucky.FormatData(id,"{:url('audit')}","确认批量审核?");
                return  false;
            }else if(obj.event==="auditall"){
                lucky.FormatData((1,2),"{:url('auditall')}","确认全部审核?");
                return  false;
            }
        });

        /**
         * 关键词搜索树
         */
        form.on('submit(search)', function (obj) {
            lucky.CreateSearch(obj.field);
            return false;
        });
    });

</script >

{/block}
